﻿using System;
using System.Web.UI.WebControls;
using BLL.RF.SourceCategory;

public partial class ViewbyProduct_ViewRFSourceData_ViewVSWRCheckItembySNDT : System.Web.UI.Page
{    
    private VSWRCheckItem fci;

    public ViewbyProduct_ViewRFSourceData_ViewVSWRCheckItembySNDT()
    {
        fci = new VSWRCheckItem();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["ProductSN"] != null && Request.QueryString["recordTime"] != null)
            {
                string productSN = Request.QueryString["ProductSN"];
                string rdstr = Request.QueryString["recordTime"].ToString();
                string rdstrformat = rdstr.Substring(0, 4) + "-" + rdstr.Substring(4, 2) + "-" + rdstr.Substring(6, 2) 
                    + " " + rdstr.Substring(8, 2) + ":" + rdstr.Substring(10, 2) + ":" + rdstr.Substring(12, 2);
                DateTime recordTime = DateTime.Parse(rdstrformat);

                BindGV(productSN, recordTime);
            }
        }
    }

    private void BindGV(string productSN, DateTime recordTime)
    {
        GridView1.DataSource = fci.GetVSWRCheckItembySNDT(productSN, recordTime);
        GridView1.DataBind();
    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //if (e.Row.Cells[4].Text == "True")
            if ((bool)GridView1.DataKeys[e.Row.RowIndex].Values[2] == true)
            {
                e.Row.Cells[6].Text = "Pass";
            }
            else
            {
                e.Row.Cells[6].Text = "Fail";
                e.Row.Cells[6].ForeColor = System.Drawing.Color.Red;
            }
        }
    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[6].Attributes.Add("style", "word-break :break-all ; word-wrap:break-word");
        }
    }
}
